import { createRouter, createWebHistory } from 'vue-router'

import { accessRoutes, routes } from './routes'
import type { App } from 'vue'
import createRouterGuard from './guard'
import { pubsubHandler } from './pubsub'
import { generateAccess } from './access'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: routes,
})

export function setupRouter(app: App) {
  generateAccess(router, accessRoutes)
  app.use(router)
  createRouterGuard(router)
  pubsubHandler(router)
}
export default router
